capture git hash on github action builds. (#816)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Tue, 11 Jan 2022 15:07:24 +0000 (08:07 -0700)
committerGitHub <noreply@github.com>
Tue, 11 Jan 2022 15:07:24 +0000 (08:07 -0700)
* capture git hash on github action builds.

* modernize version sha display

* delete stray space

gbversion.cmake
gbversion.h.in
gbversion.h.qmake.in
gbversion.pri
gui/aboutdlg.cc
gui/aboutdlg.h
gui/aboutui.ui
gui/mainwindow.cc
main.cc

index dc6f1a55f437eaf90cf166e54bd7d88e38f15c8d..6d64a28c22364270efd7e0c228018f25a5661dda 100644 (file)
@@ -23,6 +23,7 @@ list(GET VERSION_COMPONENTS 2 GB.MICRO)
 # A: it's used by win32/gpsbabel.rc which includes gbversion.h
 set(GB.BUILD 31 CACHE STRING "Fourth component of Windows VERSIONINFO resource FILEVERSION and PRODUCTVERSION parameters.")
 set(GB.PACKAGE_RELEASE "" CACHE STRING "String to append to VERSION tuple.") # .e.g. "-beta20190413"
+set(GB.SHA $ENV{GITHUB_SHA})
 
 # may be overridden on cmake command line
 set(DOCVERSION ${GB.VERSION} CACHE STRING "String appended to documentation location for www.gpsbabel.org.")
index 4778bfb39f0c299b6e32a65858cdc6223dcec99d..b88226a7617a255e533d96a5c59a271724282f76 100644 (file)
@@ -10,8 +10,9 @@
 #define VER_FILE @GB.MAJOR@,@GB.MINOR@,@GB.MICRO@,@GB.BUILD@
 #define VER_PRODUCT @GB.MAJOR@,@GB.MINOR@,@GB.MICRO@,@GB.BUILD@
 #define VER_FILE_STR "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@"
-#define VER_PRODUCT_STR  "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@"
+#define VER_PRODUCT_STR "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@"
 #else
 #define VERSION "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@"
+constexpr char kVersionSHA[] = "@GB.SHA@";
 #define WEB_DOC_DIR "https://www.gpsbabel.org/htmldoc-@DOCVERSION@"
 #endif
index ead3c6199ce50153ca6af55b107f477d51e69f18..1b50b954888dd533cd8d4da8c0078b0ceb7534db 100644 (file)
@@ -10,8 +10,9 @@
 #define VER_FILE $${GB.MAJOR},$${GB.MINOR},$${GB.MICRO},$${GB.BUILD}
 #define VER_PRODUCT $${GB.MAJOR},$${GB.MINOR},$${GB.MICRO},$${GB.BUILD}
 #define VER_FILE_STR \"$${GB.MAJOR}.$${GB.MINOR}.$${GB.MICRO}$${GB.PACKAGE_RELEASE}\"
-#define VER_PRODUCT_STR  \"$${GB.MAJOR}.$${GB.MINOR}.$${GB.MICRO}$${GB.PACKAGE_RELEASE}\"
+#define VER_PRODUCT_STR \"$${GB.MAJOR}.$${GB.MINOR}.$${GB.MICRO}$${GB.PACKAGE_RELEASE}\"
 #else
 #define VERSION \"$${GB.MAJOR}.$${GB.MINOR}.$${GB.MICRO}$${GB.PACKAGE_RELEASE}\"
+constexpr char kVersionSHA[] = \"$${GB.SHA}\";
 #define WEB_DOC_DIR \"https://www.gpsbabel.org/htmldoc-$${DOCVERSION}\"
 #endif
index 9967e97007153f919bf0130c3de99458a95188cf..f5f74074e795eabde93511275acc5abe0e2b96df 100644 (file)
@@ -23,6 +23,7 @@ GB.MICRO = $$member(GB.VERSION_COMPONENTS, 2)
 # A: it's used by win32/gpsbabel.rc which includes gbversion.h
 GB.BUILD = 31
 # GB.PACKAGE_RELEASE = "-beta20190413"
+GB.SHA = $$(GITHUB_SHA)
 
 # may be overridden on qmake command line
 !defined(DOCVERSION, var) {
index 3e92bbe4f883bb70c506e25a7cda94697ff5b6b8..e98427924c2feea8729fcf28ef7da92d9032c3e8 100644 (file)
@@ -29,7 +29,8 @@
 
 
 AboutDlg::AboutDlg(QWidget* parent, const QString& ver1,
-                   const QString& ver2, const QString& installationId): QDialog(parent)
+                   const QString& ver2, const QString& ver3,
+                   const QString& installationId): QDialog(parent)
 {
   ui_.setupUi(this);
   QTextDocument* doc = ui_.textEdit->document();
@@ -38,6 +39,11 @@ AboutDlg::AboutDlg(QWidget* parent, const QString& ver1,
   tt.replace("$appname$", appName);
   tt.replace("$babelversion$", ver1);
   tt.replace("$babelfeversion$", ver2);
+  if (ver3.isEmpty()) {
+    tt.replace("$hash$", "");
+  } else {
+    tt.replace("$hash$", "Hash: " + ver3);
+  }
   tt.replace("$installationId$", installationId);
 
   // Not localized as it should never be seen.
index a93ac2a6d515393fcfc3f24872ef38f249d96cbe..d20ca0af850922eb25d96f4c60723d246415d46c 100644 (file)
@@ -32,7 +32,8 @@ class AboutDlg: public QDialog
 {
 public:
   AboutDlg(QWidget* parent,  const QString& ver1,
-           const QString& ver2, const QString& installationId);
+           const QString& ver2, const QString& ver3,
+           const QString& installationId);
 
 private:
   Ui_AboutDlg  ui_;
index 48eb2c7d96727638ef8fd389a1f12db35cdb5fe0..bfd741e3d4ad68bb55917740231c84beddd1cc5b 100644 (file)
        </property>
        <property name="html">
         <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
 p, li { white-space: pre-wrap; }
 &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt; font-weight:600;&quot;&gt;$appname$&lt;/span&gt;&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;$babelfeversion$&lt;/span&gt;&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;Copyright (C) 2009-2016 Robert Lipe&lt;/span&gt;&lt;/p&gt;
-&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;GUI designed and contributed by  S. Khai Mong&lt;/span&gt;&lt;/p&gt;
+&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;GUI designed and contributed by S. Khai Mong&lt;/span&gt;&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;LGPL Crystal Icons by Elvarado Coehlo&lt;/span&gt;&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;(Using backend $babelversion$)&lt;/span&gt;&lt;/p&gt;
+&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;$hash$&lt;/span&gt;&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;$upgradetestmode$&lt;/span&gt;&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;Installation ID: $installationId$&lt;/span&gt;&lt;/p&gt;
 &lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;This program is free software; you can redistribute it and/or  modify it under the terms of the GNU General Public License as  published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.&lt;/span&gt;&lt;/p&gt;
 &lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.&lt;/span&gt;&lt;/p&gt;
 &lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
index d4b153b50828d16ccca10775f78d25d0e1d366c8..c76fa7f9c71c21641bcb98c2738ccf3a01d34f1f 100644 (file)
@@ -1159,7 +1159,7 @@ void MainWindow::moreOptionButtonClicked()
 //------------------------------------------------------------------------
 void MainWindow::aboutActionX()
 {
-  AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), babelData_.installationUuid_);
+  AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), kVersionSHA, babelData_.installationUuid_);
   aboutDlg.setWindowTitle(tr("About %1").arg(appName));
   aboutDlg.exec();
 }
diff --git a/main.cc b/main.cc
index c3d2aa490fdbcff750995b3d815a581b238daebd..70d277d2c227399f4c4768ca33d1e6b145938478 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -48,6 +48,7 @@
 #include "filter.h"                   // for Filter
 #include "filter_vecs.h"              // for FilterVecs
 #include "format.h"                   // for Format
+#include "gbversion.h"                // for VERSION_SHA
 #include "inifile.h"                  // for inifile_done, inifile_init
 #include "session.h"                  // for start_session, session_exit, session_init
 #include "src/core/datetime.h"        // for DateTime
@@ -432,6 +433,9 @@ run(const char* prog_name)
        */
       if (global_opts.debug_level > 0)  {
         warning("GPSBabel Version: %s\n", gpsbabel_version);
+        if(sizeof(kVersionSHA) > 1) {
+          warning(MYNAME ": Repository SHA: %s\n", kVersionSHA);
+        }
         warning(MYNAME ": Compiled with Qt %s for architecture %s\n",
                 QT_VERSION_STR,
                 qPrintable(QSysInfo::buildAbi()));